define(function () {
    'use strict';
    function ctrl($scope, $state, LocalCacheService, CommonService, WTService) {
        function init() {
            $scope.user = LocalCacheService.getUser();
            $scope.formEvents = {
                submit: function () {
                    ///提交成功后跳转
                    WTService.modifyZipcode($scope.user.zipcode).then(
                        function () {
                            LocalCacheService.setUser($scope.user);
                            $state.go('tab.account-manager');
                        }, function () {
                            CommonService.showAlert({message: "修改失败"});
                        }
                    )
                }
            }
        }

        $scope.$on('$ionicView.beforeEnter', function () {
            init();
        });
    }

    ctrl.$inject = ['$scope', '$state', 'LocalCacheService', 'CommonService', 'WTService'];
    return ctrl;
});